/*
 * @Description: 
 * @Author: Xiaochuan-W
 * @Date: 2023-10-30 15:20:47
 * @LastEditors: Xiaochuan-W
 * @LastEditTime: 2024-08-30 09:49:34
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path';

export default defineConfig({
  base: './',
  server: {
    host: true,
    port: 1573
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
      types: resolve(__dirname, 'src/types'),
      components: resolve(__dirname, 'src/components')
    }
  },
  build: {
    minify: 'terser', // 压缩工具
    outDir:'@wooshiao/dist',
    terserOptions: {
      // 打包移除console
      compress: {
        keep_infinity: true,
        drop_console: true,
        drop_debugger: true
      }
    },
    rollupOptions:{
      external: ["vue","ace-builds","tinymce","@tinymce/tinymce-vue","vue-router","element-plus","@element-plus/icons-vue",'ace-builds/src-noconflict/mode-yaml',
      'ace-builds/src-noconflict/mode-sql',
      'ace-builds/src-noconflict/mode-javascript',
      'ace-builds/src-noconflict/mode-markdown',
      'ace-builds/src-noconflict/mode-java',
      'ace-builds/src-noconflict/mode-json',
      'ace-builds/src-noconflict/worker-yaml',
      'ace-builds/src-noconflict/worker-javascript',
      'ace-builds/src-noconflict/theme-chrome',],
      output: {
        globals: {
          vue: "Vue",
          'ace-builds': "ace",
          'tinymce': "Tinymce",
          '@tinymce/tinymce-vue': "TinymceVue",
          'vue-router': "VueRouter",
          'element-plus': "ElementPlus",
          '@element-plus/icons-vue': "ElementPlusIconsVue",
          'ace-builds/src-noconflict/mode-yaml':'ModeYaml',
          'ace-builds/src-noconflict/mode-sql':'ModeSql',
          'ace-builds/src-noconflict/mode-javascript':'ModeJavascript',
          'ace-builds/src-noconflict/mode-markdown':'ModeMarkdown',
          'ace-builds/src-noconflict/mode-java':'ModeJava',
          'ace-builds/src-noconflict/mode-json':'ModeJson',
          'ace-builds/src-noconflict/worker-yaml':'WorkerYaml',
          'ace-builds/src-noconflict/worker-javascript':'WorkerJavascript',
          'ace-builds/src-noconflict/theme-chrome':'ThemeChrome',
        }
      }
    },
    lib: {
      entry: "src/components/index.ts",
      name: "XUI",
      fileName: "x-ui",
      // 导出模块格式
      formats: ['es', 'umd'],
    },
  },
  
  plugins: [
    vue()
  ],
})
